package com.wee.cronos.client.core.presenter;

import java.util.ArrayList;

 import com.google.web.bindery.event.shared.EventBus;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.NameToken;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.ProxyPlace;
import com.gwtplatform.mvp.client.proxy.RevealContentEvent;
import com.wee.cronos.client.core.view.ProjectExplorerViewImpl.ProjectExplorerUiHandlers;
import com.wee.cronos.client.place.NameTokens;
import com.wee.cronos.shared.ProjectDetails;

public class ProjectExplorerPresenter extends Presenter<ProjectExplorerPresenter.ProjectExplorerView, ProjectExplorerPresenter.ProjectExplorerProxy> implements ProjectExplorerUiHandlers
{
	public interface ProjectExplorerView extends View, HasUiHandlers<ProjectExplorerUiHandlers> 
	{
		void setProjectList(ArrayList<ProjectDetails> projectInfo);
	}
	
	@ProxyCodeSplit
	@NameToken(NameTokens.projectExplorer)
	public interface ProjectExplorerProxy extends ProxyPlace<ProjectExplorerPresenter> {}
	
	@Inject
	public ProjectExplorerPresenter(EventBus eventBus, ProjectExplorerView view, ProjectExplorerProxy proxy) 
	{
		super(eventBus, view, proxy);
		getView().setUiHandlers(this);
	}

	@Override
	protected void revealInParent() 
	{
		RevealContentEvent.fire(this, ProjectManagementPresenter.TYPE_RevealProjectExplorer, this);
	}

	@Override
	public void fetchProjectInfo() 
	{
		ArrayList<ProjectDetails> list = new ArrayList<ProjectDetails>();
		ProjectDetails pd = new ProjectDetails();
		pd.setName("Testando nova arquitetura!");
		list.add(pd);
		getView().setProjectList(list);
	}
}
